#include "../include/reporter.hpp"
#include "../include/sys_var.hpp"

reporter :: reporter():
	m_timer( [this]{
		// 执行上报操作
		run();
		// 重新启动计时器
		m_timer.Start( -1 , true );
	 } ,1 ,true )
{
	std::shared_ptr< CSysVar > ptvar = GetOrCreateSysVar();
	if( ptvar ){
		bool sw;
		long intval ;
		ptvar -> GetValue( "/signal/reporter/url" , m_url );
		ptvar -> GetValue( "/signal/reporter/port" , m_port );
		ptvar -> GetValue( "/signal/reporter/intval" , intval );
		m_timer( intval );

		ptvar -> GetValue( "/signal/reporter/en_loc" , sw );
		m_loc = sw;
		
		ptvar -> GetValue( "/signal/reporter/en_socka" , sw );
		m_socka = sw;

		ptvar -> GetValue( "/signal/reporter/en_sockb" , sw );
		m_sockb = sw;

		ptvar -> GetValue( "/signal/reporter/en_sockc" , sw );
		m_sockc = sw;
		
		ptvar -> GetValue( "/signal/reporter/en_sockd" , sw );
		m_sockd = sw;

		ptvar -> GetValue( "/signal/reporter/en_net" , sw );
		m_net = sw;
		
		ptvar -> GetValue( "/signal/reporter/en_radio" , sw );
		m_radio = sw;
	}
}


reporter :: ~reporter()
{
}

void reporter :: run()
{
	// 执行收集信息操作
	collect();

	// 执行发送信息操作
	if( m_loc ){
	}

	if( m_socka ){
	}

	if( m_sockb ){
	}

	if( m_sockc ){
	}

	if( m_sockd ){
	}
}

void reporter :: collect()
{
	if( m_loc ){
	}

	if( m_socka ){
	}

	if( m_sockb ){
	}

	if( m_sockc ){
	}

	if( m_sockd ){
	}	
}

